using GEM.Domain.Entities.App;

namespace GEM.Domain.DomainServices;

public class RbacDomainService
{
    // 判断某个用户是否对指定资源拥有某种权限。
    public bool UserHasResourecePermission(AppUser user, string resourcePath, string permissionCode)
    {
        return user.Roles.Any(role =>
        role.AppPermissions.Any(permission =>
        permission.Code == permissionCode &&
        permission.AppResourses.Any(resource => resource.Path == resourcePath)));
    }
}